package com.bluefish.bltuan.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bluefish.bltuan.dao.EmailSettingDao;
import com.bluefish.bltuan.module.mail.EmailSetting;
import com.bluefish.bltuan.service.EmailSettingService;

@Service
@Transactional
public class EmailSettingServiceImpl implements EmailSettingService{

	private EmailSettingDao emailSettingDao;
	
	public void delete(EmailSetting t) {
		this.emailSettingDao.delete(t);
	}

	public EmailSetting findById(Integer id) {
		return this.emailSettingDao.findById(id);
	}

	public void save(EmailSetting t) {
		this.emailSettingDao.save(t);
	}

	public void update(EmailSetting t) {
		this.emailSettingDao.update(t);
	}
	
	public void saveOrUpdate(EmailSetting t) {
		this.emailSettingDao.saveOrUpdate(t);
	}

	public void setEmailSettingDao(EmailSettingDao emailSettingDao) {
		this.emailSettingDao = emailSettingDao;
	}
	
	public EmailSetting getEmailSetting() {
		List<EmailSetting> settings = this.emailSettingDao.list();
		return settings != null && settings.size() > 0 ? 
				settings.get(0) : null;
	}
}
